package com.intellif.spring_boot_autoconfiguration.bootstrap;

import com.intellif.spring_boot_autoconfiguration.condition.ConditionOnSystemProperty;
import com.intellif.spring_boot_autoconfiguration.service.CalculateService;
import org.springframework.boot.WebApplicationType;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.Bean;

/**
 * 系统属性条件引导类
 */
public class ConditionOnSystemPropertyBootstrap {

    @Bean
    @ConditionOnSystemProperty(name = "user.name",value = "liuwei")
    public String helloWorld(){
        return "helloworld";
    }
    public static void main(String[] args) {
        ConfigurableApplicationContext applicationContext = new SpringApplicationBuilder(ConditionOnSystemPropertyBootstrap.class).
                web(WebApplicationType.NONE).
                run(args);
        String helloWorld = applicationContext.getBean("helloWorld", String.class);
        System.out.println("helloWorld bean:"+helloWorld);
        applicationContext.close();
    }

}
